package views.accounting;

import java.awt.Component;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.SystemColor;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JToolBar;
import javax.swing.SpringLayout;
import javax.swing.SwingConstants;

import uiframework.UIFrameWork;
import controller.AccountingController;

public class AccountingView extends JPanel implements MouseListener
{
	private JLabel btnAccount;
	private JLabel[]leftMenu;
	private JToolBar toolBar;
	private SpringLayout springLayout;
	
	public AccountingView()
	{
		springLayout = new SpringLayout();
		setLayout(springLayout);
		setSize(1050,550);
		
		toolBar = new JToolBar();
		toolBar.setBackground(SystemColor.inactiveCaption);
		toolBar.setBorder(null);
		toolBar.setOrientation(SwingConstants.VERTICAL);
		springLayout.putConstraint(SpringLayout.SOUTH, toolBar, 0, SpringLayout.SOUTH, this);
		springLayout.putConstraint(SpringLayout.NORTH, toolBar, 3, SpringLayout.NORTH, this);
		springLayout.putConstraint(SpringLayout.WEST, toolBar, 0, SpringLayout.WEST, this);
		springLayout.putConstraint(SpringLayout.EAST, toolBar, 180, SpringLayout.WEST, this);
		makeLeftMenu();
		addButtonsInToolBar();
		addButtonListener();
		add(toolBar);	
	}

	private void makeLeftMenu()
	{
		leftMenu=new JLabel[1];
		btnAccount= new JLabel("ACCOUNTING",SwingConstants.CENTER);
		btnAccount.setMinimumSize(new Dimension(180, 40));
		btnAccount.setMaximumSize(new Dimension(180, 40));
		btnAccount.setPreferredSize(new Dimension(72, 40));
		btnAccount.setAlignmentX(Component.CENTER_ALIGNMENT);
		btnAccount.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		leftMenu[0]=btnAccount;
		
		for(int k=0;k<leftMenu.length;k++)
			leftMenu[k].setBorder(null);
	}
	
	private void addButtonsInToolBar()
	{
		toolBar.add(btnAccount);
		toolBar.addSeparator();	
	}
	
	private void addButtonListener()
	{
		for(JLabel temp:this.leftMenu)
			 temp.addMouseListener(this);
	}
	
	@Override
	public void mouseClicked(MouseEvent e) {
		if(e.getSource() instanceof JLabel)
		{
			JLabel button=(JLabel) e.getSource();
			if(button==btnAccount)
			{	
				Accounting view=new Accounting();
				UIFrameWork.setReportComponent(springLayout, view,this,2);
				AccountingController cont=new AccountingController(view,null);
			}
		}
		
	}

	@Override
	public void mouseEntered(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mouseExited(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mousePressed(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mouseReleased(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

}
